<?php

namespace models;

use Unirest\Request;

class Commodity {
		
	/** 获取菜场里所有蔬菜 **/
	public static function getByMarketId($marketId) {
		$headers = array('Accept' => 'application/json');
		$query = array('marketId' => $marketId);
		$response = Request::post(C_API . '/wx_CommodityAvgPriceListJson.action', $headers, $query);
		if($response->code == 200) {
			return $response->body;
		}
    }
    
    /** 获取所有蔬菜的价格 **/
	public static function getPrices($cid, $typeId) {
		$headers = array('Accept' => 'application/json');
		$query = array('commodityId' => $cid, 'typeId' => $typeId);
		$response = Request::post(C_API . "/wx_MarketCommodityAvgPriceListJson.action", $headers, $query);
		if($response->code == 200) {
			return $response->body;
		}
    }
}

